//在这个页面进行接收参数,并将参数传递给service

import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { TaskService } from './task.service';
import { CreateTaskDto } from './dto/create-task.dto';
import { UpdateTaskDto } from './dto/update-task.dto';

@Controller('task')
export class TaskController {
  constructor(private readonly taskService: TaskService) {}

  @Post('create')
  create(@Body() createTaskDto: CreateTaskDto) {
    return this.taskService.create(createTaskDto);
  }

  @Get('page')
  page(@Query('page') page: number, @Query('pageSize') pageSize: number) {
    return this.taskService.page(page, pageSize);
  }

  @Get('get')
  get(@Query('id') id: number) {
    return this.taskService.findOne(id);
  }

  @Patch('update')
  update(@Body() updateTaskDto: UpdateTaskDto) {
    return this.taskService.update(updateTaskDto);
  }

  @Delete('delete')
  remove(@Query('id') id: string) {
    return this.taskService.remove(+id);
  }

  @Get('list')
  findAll() {
    return this.taskService.page(1, -1);
  }
}
